import React from 'react';

import show from './show';

import Modal from './modal';

import * as Const from "../../const";

import {
    AlertOpt
} from './types';

export default (opt: AlertOpt) => (
    new Promise((resolve) => {
        const {
            title,
            message,
            buttonText,
            showClose = true
        } = opt || {};

        const button = {
            onPress: resolve,
            text: buttonText || `OK`,
            textStyle: {color: Const.color}
        }

        const props = {
            showClose:showClose,
            message: message,
            buttons: [button],
            title: title || `Notice`
        }

        show(<Modal {...props}/>);
    })
)